package com.sgb.zhaocai.view.adapter;


import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.zhaocai.BR;
import com.sgb.zhaocai.R;
import com.sgb.zhaocai.entity.AddInviteExternalListBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class WebSiteAdapter extends BaseRecycleAdapter<AddInviteExternalListBean.AddInviteDataBean> {

    private IChildClick iChildClick;

    public WebSiteAdapter(Context context, List<AddInviteExternalListBean.AddInviteDataBean> datas) {
        super(context, R.layout.item_website_list, datas);
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        TextView editor = holder.itemView.findViewById(R.id.editor);
        TextView delete = holder.itemView.findViewById(R.id.delete);
        editor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                iChildClick.editor(position);
            }
        });
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                iChildClick.delete(position);
            }
        });
    }

    @Override
    public void convert(ItemViewHolder holder, final AddInviteExternalListBean.AddInviteDataBean entity) {
        holder.setBinding(BR.viewModel, entity);
    }

    public interface IChildClick {

        void editor(int position);

        void delete(int position);
    }

    public void onIChildClick(IChildClick iChildClick) {
        this.iChildClick = iChildClick;
    }
}
